#include "QPushButton"
#include "QLabel"
#include <qfont.h>
#include "game.h"
#include "mainwindow.h"
#include "dialog.h"
dialog::dialog(QString str,int a,int b,int c,int time)
{
    len = a;
    wid = b;
    num = c;
    QLabel * label = new QLabel;
    QFont font;
    font.setPointSize(20);
    label->setFont(font);
    label->setParent(this);
    label->setText(str);
    label->move(150,110);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    label->show();
    if(time != -1){
        QLabel * time_label = new QLabel;
        QLabel * text_2 = new QLabel;
        font.setPointSize(15);
        text_2->setFont(font);
        text_2->setParent(this);
        text_2->setText("使用时间：      秒");
        text_2->move(150,210);
        text_2->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        text_2->show();
        time_label->setFont(font);
        time_label->setParent(this);
        time_label->setText(QString::number(time));
        time_label->move(330,210);
        time_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        time_label->show();
    }
    this->setFixedSize(800,400);
    QPushButton * startbtn = new QPushButton("开始新游戏",this);
    startbtn->resize(200,80);
    connect(startbtn,&QPushButton::clicked,[=](){
        emit this->newgame();
        gamescene = new game(nullptr,len,wid,num);
        gamescene->show();
        this->hide();
    });
    startbtn->move(this->width()*0.1,this->height()*0.75);
    //QPushButton * restartbtn = new QPushButton("重新开始这局游戏",this);
    //restartbtn->resize(200,80);
    //restartbtn->move(this->width()*0.375,this->height()*0.75);
    QPushButton * backbtn = new QPushButton("返回主菜单",this);
    backbtn->resize(200,80);
    connect(backbtn,&QPushButton::clicked,[=](){
        emit this->Backtomenu();
        this->close();
        MainWindow * window = new MainWindow();
        window->show();
    });
    backbtn->move(this->width()*0.65,this->height()*0.75);
}
